#include"Comm.hpp"
//read
using namespace std;
int main()
{
    CreatePipe(NAME_PIPE);
    int fd = open(NAME_PIPE,O_RDONLY);
    if(fd == -1)
    cout<<"打开文件错误"<<endl;
    char buffer[1024];
    while(1)
    {
        //减一目的是将读到的东西当作字符串去处理，将最后一位留出来以便\0
        int n = read(fd,buffer,sizeof(buffer)-1);
        if(n > 0)
        {
            buffer[n] = 0;
            cout<<"client->server#"<<buffer<<endl;
        }
        else 
        {
            cout<<"写进程都润了，我也润"<<endl;
            break;
        }
        
    }
    close(fd);
    RemovePipe(NAME_PIPE);
}